/*
 * @Author: 陈永浩(cyh1231wp@163.com)
 * @Date: 2020-11-03 12:48:28
 * @LastEditors: 陈永浩(cyh1231wp@163.com)
 * @LastEditTime: 2020-12-21 16:11:43
 */
const path = require('path')
const { title } = require('./src/config/settings')
const { version, author } = require('./package.json')
const dayjs = require('dayjs')
const date = dayjs().format('YYYY_M_D')
const time = dayjs().format('YYYY-M-D HH:mm:ss')
const productionGzipExtensions = ['html', 'js', 'css', 'svg']
process.env.VUE_APP_TITLE = title || 'saasjs-framework-vue'
process.env.VUE_APP_AUTHOR = author || 'cyh(cyh1231wp@163.com)'
process.env.VUE_APP_UPDATE_TIME = time
process.env.VUE_APP_VERSION = version


module.exports = {
  devServer: {
    proxy: {
      'v1': {
        target: 'http://127.0.0.1:3000',
        changeOrigin: true,
        pathRewrite: {
          '^/v1': ''
        }
      }
    }
  },
  productionSourceMap: false,
  css: {
    requireModuleExtension: true,
    sourceMap: false,
    loaderOptions: {
      scss: {
        /*sass-loader 8.0语法 */
        //prependData: '@import "~@/styles/variables.scss";',

        /*sass-loader 9.0写法，感谢github用户 shaonialife*/
        additionalData(content, loaderContext) {
          const { resourcePath, rootContext } = loaderContext
          const relativePath = path.relative(rootContext, resourcePath)
          if (
            relativePath.replace(/\\/g, '/') !== 'src/styles/variables.scss'
          ) {

            return '@import "~@/styles/variables.scss";' + content
          }
          return content
        },
      },
    },
  },
}
